package utils.map;

public class TimeLimitKey implements Limit {
    private int count = 0;
    private int total = 0;

    public TimeLimitKey(int total) {
        super();
        if (total <= 0) {
            return;
        }
        this.count = total;
        this.total = total;
    }

    @Override
    public boolean isExpired() {
        return count <= 0;
    }

    @Override
    public void expire() {
        count = 0;
    }

    @Override
    public void renew() {
        count = total;
    }

    @Override
    public Limit copy() {
        return new TimeLimitKey(total);
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    @Override
    public void use() {
        count -= 1;
    }

}
